import { defineStore } from 'pinia'
import { reactive } from 'vue'
import axios from 'axios'
export const useQuestionStore = defineStore('question', () => {
    const state = reactive({
        questionList: [],
        itemNum: 1, // 第几题
        answerList: [] // 选中的答案
    })

    function getQuestionList() {
        axios.get('https://mock.mengxuegu.com/mock/65a7d72cb674c730aaefdcea/example/question')
        .then(res => {
            console.log(res.data.questions);
            state.questionList = res.data.questions
        })
    }

    function saveAnswerList(index) {
        state.answerList.push(index)
    }
    function setItemNum() {
        state.itemNum++
    }
    return {
        state,
        getQuestionList,
        setItemNum,
        saveAnswerList
    }
})